  <%
    image_rowspan = 9
    show_authors    = !material.authors.nil? &&  material.authors.size > 0
    show_publishers = !material.publishers.nil? &&  material.publishers.size > 0
    show_collection = !material.collection.nil? && material.collection != ""
    show_isbn       = !material.isbn.nil? && material.isbn != ""
    show_comment    = !material.comment.nil? && material.comment != ""
    show_descriptors = !material.descriptors.nil? &&  material.descriptors.size > 0
    show_price       = !material.price.nil? && material.price > 0
    image_rowspan -= 1 if !show_authors
    image_rowspan -= 1 if !show_publishers
    image_rowspan -= 1 if !show_collection
    image_rowspan -= 1 if !show_isbn
    image_rowspan -= 2 if !show_comment
    image_rowspan -= 1 if !show_descriptors
    image_rowspan -= 1 if !show_price
  %>

  <table width="100%" border="0" id="contenido" style="margin:0 0 5pt 0;border-bottom: 1pt #999 dotted;">
    <tr>
      <td width="160" rowspan=<%="#{image_rowspan}"%> style="text-align: center;vertical-align: top;">
      <table>
        <tr style="vertical-align: top">
          <td><%= "#{index}. " %></td>
          <td>
            <% image_path = "#{Setting.url_base.strip}/#{Setting.image_path_relative.strip}/#{material.image.strip} " %>
            <%= image_tag(image_path, :alt => "#{t('label_image_text_alt')}", :size => "150x200" ) %>
          </td>
        </tr>
      </table>
      </td>
      <td colspan="2" style="text-align: center;vertical-align: middle;">
        <h2 style="font-family: Calibri, Arial, 'Arial Black';font-size: 18px;font-weight: bold;color:#036;margin: 2px 0 0 20px;text-align: justify;">

          <%
             title = material.title
             if !material.sub_title.nil? && material.sub_title != ""
               title += " : #{material.sub_title}"
             end
          %>
          <%= title%>
        </h2>
      </td>
    </tr>

    <% if show_authors %>
      <tr>
        <td width="85"  style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.models.author')%>:</b>
          </h4>
        </td>
        <td  style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <% first = true %>
            <% material.authors.each do |autor|%>
              <%="#{autor.last_name} , #{autor.first_name}"%>
              <% if !first %>
               -
              <% end %>
              <% first = false %>
            <% end %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_publishers %>
      <tr>
        <td width="85"  style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.models.publisher')%>:</b>
          </h4>
        </td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <% first = true %>
            <% material.publishers.each do |publisher|%>
              <%="#{publisher.city.name} : #{publisher.name}" %>
              <% if !first %>
                <br/>
              <% end %>
              <% first = false %>
            <% end %>
            <% if !material.edition_year.nil? && material.edition_year != 0 %>
              <%= ", #{material.edition_year}."%>
            <% end %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_collection  %>
      <tr>
        <td width="85"  style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.attributes.material.collection')%>:</b>
          </h4>
        </td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <%= material.collection %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_isbn  %>
      <tr>
        <td width="85"  style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.attributes.material.isbn')%>:</b>
          </h4>
        </td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <%= material.isbn %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_comment %>
      <tr>
        <td width="85" style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.attributes.material.comment')%>:</b>
          </h4>
        </td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <% if !material.pages.nil? && material.pages != "" %>
              <%= material.pages %> p.;
            <% end %>
            <% if !material.height.nil? && material.height != "" %>
              <%= material.height %> cm.
            <% end %>
          </h3>
        </td>
      </tr>
      <tr>
        <td width="85" style="text-align: center;vertical-align: middle;">&nbsp;</td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <%= material.comment %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_descriptors %>
      <tr>
        <!--td width="160" style="text-align: center;vertical-align: middle;">&nbsp;</td-->
        <td style="text-align: center;vertical-align: middle;"></td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <% material.descriptors.each do |descriptor|%>
              /
              <%=descriptor.description%>
            <% end %>
          </h3>
        </td>
      </tr>
    <% end %>
    <% if show_price   %>
      <tr>
        <!--td style="text-align: center;vertical-align: middle;">&nbsp;</td-->
        <td style="text-align: center;vertical-align: middle;">
          <h4 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: right;vertical-align:top;">
            <b><%=t('activerecord.attributes.material.price')%>:</b>
          </h4>
        </td>
        <td style="text-align: center;vertical-align: middle;">
          <h3 style="font-family: Calibri, Arial, 'Arial Black';font-size: 10pt;font-weight: normal;margin: 2px;text-align: left;">
            <%="#{material.currency.symbol} #{"%.2f" % material.price}" %>
          </h3>
        </td>
      </tr>
    <% end %>
  </table>